package action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ModelDriven;

import pageModel.Receipt;
import pageModel.SaleHighchart;
import service.ReceiptServiceI;
import service.ShopListServiceI;

@Action(value="saleChartAction")
public class SaleChartAction extends BaseAction implements ModelDriven<Receipt>{
	private String result;
	private ReceiptServiceI receiptService;
	private ShopListServiceI shopListService;
	Receipt receipt = new Receipt();
	
	public Receipt getModel() {
		return receipt;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public ReceiptServiceI getReceiptService() {
		return receiptService;
	}
	@Autowired
	public void setReceiptService(ReceiptServiceI receiptService) {
		this.receiptService = receiptService;
	}
	
	public ShopListServiceI getShopListService() {
		return shopListService;
	}
	@Autowired
	public void setShopListService(ShopListServiceI shopListService) {
		this.shopListService = shopListService;
	}
	public String saleHighChart(){
		List<SaleHighchart> r=receiptService.highChart(receipt);
		result=super.writeJson(r);
		return result;	
	}
	public String productHighChart(){
		List<SaleHighchart> r=shopListService.highChart(receipt);
		result=super.writeJson(r);
		return result;	
	}
	public String amountHighChart(){
		List<SaleHighchart> r=shopListService.saleHighChart(receipt);
		result=super.writeJson(r);
		return result;	
	}
}
